<?php
/**
 * @link http://cn2.php.net/manual/en/migration54.incompatible.php
 * @version $Id: 6_timezone.php 211 2012-03-02 10:56:14Z horseluke@126.com $
 */

/*
In the date and time extension, the timezone can no longer 
be set using the TZ environment variable. Instead you have 
to specify a timezone using the date.timezone ini option or
date_default_timezone_set() function. PHP will no longer 
attempt to guess the timezone, and will instead fall back to 
"UTC" and issue a warning.

备注：
意思似乎是指，不再读取由操作系统、web server等设置的TZ。
也就是说，类似以下的技巧将失效：
If you are using PHP 4.3, 4.4 or 5.0 export the TZ environment variable 
in your web server configuration. If you are using an Apache web server, 
do this using the SetEnv directive in httpd.conf:
SetEnv TZ Europe/London 

这个脚本只是用putenv模拟一下这个过程，不一定有效。
（至少我5.2正常使用UTC+8；但5.3和5.4一样报错而使用了UTC+8）
如果模拟不了，检查php.ini是不是设置了date.timezone，设置了就不会出错了。

如有兴趣请查阅下面的相关链接：
http://www.mail-archive.com/internals@lists.php.net/msg53310.html

PHP 5.2:

2012-03-02 17:31:35

PHP 5.3:


Warning: date(): It is not safe to rely on the system's timezone settings. You a
re *required* to use the date.timezone setting or the date_default_timezone_set(
) function. In case you used any of those methods and you are still getting this
 warning, you most likely misspelled the timezone identifier. We selected 'UTC'
for '8.0/no DST' instead in D:\htdoc_custom\php_5_4\6_timezone.php on line 44

Warning: date(): It is not safe to rely on the system's timezone settings. You a
re *required* to use the date.timezone setting or the date_default_timezone_set(
) function. In case you used any of those methods and you are still getting this
 warning, you most likely misspelled the timezone identifier. We selected 'UTC'
for '8.0/no DST' instead in D:\htdoc_custom\php_5_4\6_timezone.php on line 44
2012-03-02 09:32:08

PHP 5.4:


Warning: date(): It is not safe to rely on the system's timezone settings. You a
re *required* to use the date.timezone setting or the date_default_timezone_set(
) function. In case you used any of those methods and you are still getting this
 warning, you most likely misspelled the timezone identifier. We selected the ti
mezone 'UTC' for now, but please set date.timezone to select your timezone. in D
:\htdoc_custom\php_5_4\6_timezone.php on line 57
2012-03-02 09:32:28

*/

error_reporting(E_ALL);

echo ini_get('date.timezone'). "\r\n";

//@link http://cn2.php.net/manual/en/function.putenv.php
putenv('TZ=PRC');
//mktime(0,0,0,1,1,1970);

echo date('Y-m-d H:i:s');
